<template>
  <!--填写平台备注弹出框 -->
  <el-dialog title="填写平台备注" v-model="editVisible" width="30%" draggable>
    <el-input v-model="form.store_note" type="textarea" :autosize="{ minRows: 3, maxRows: 4 }" placeholder="平台备注"> </el-input>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="editVisible = false">取 消</el-button>
        <el-button type="primary" :disabled="disabledbtn" @click="submitForm">确 定 </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { useState } from "@/hooks/useState.ts";
import type { IStoreRemark } from "@/types/storeManager/store";
import { putStoreNoteInfo } from "@/utils/api/store";
const { disabledbtn, toggleState } = useState();
const emit = defineEmits<{
  handleSuccess: [];
}>();
const editVisible = defineModel<boolean>("editVisible", { required: true });
const form = defineModel<IStoreRemark>("form", { required: true });
/* 保存或编辑信息 */
function submitForm() {
  toggleState(true);
  putStoreNoteInfo(form.value)
    .then(res => {
      ElMessage.success(res.msg);
      emit("handleSuccess");
    })
    .catch(() => {})
    .finally(() => {
      toggleState(false);
    });
}
</script>

<style lang="scss" scoped></style>
